<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{$is_language?'抵押':'mortgage'}</title>
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/weui.min.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/jquery-weui.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/demos.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/example.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.2/style/weui.min.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.min.css">
    <script src="__MODULE_LIBS__/js/jquery-2.1.4.js"></script>
    <script src="__MODULE_LIBS__/js/fastclick.js"></script>
    <script src="__MODULE_LIBS__/js/jquery-weui.js"></script>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        html {
            width: 100%;
            height: 100%;
            font-size: 20px;
            font-family: "Microsoft YaHei", "宋体", "Segoe UI", "Lucida Grande", Helvetica, Arial, sans-serif, FreeSans, Arimo;
            background: #F3F3F3;
        }

        body {
            margin: 0 auto;
            max-width: 750px;
            height: 100%;
            background: #F7F7F7;
        }

        /*顶部导航栏处的样式*/
        .navbar {
            position: relative;
            width: 100%;
            height: 2rem;
            font-size: 16px;
            color: #fff;
            line-height: 2rem;
            background: #373553;
        }

        .navbar-item {
            position: absolute;
            left: 0;
            top: 0;
            display: block;
            width: 3.2rem;
            height: 2rem;
            font-size: 14px;
            color: #fff;
            text-align: center;
        }

        .navbar-item > img {
            width: 0.8rem;
            height: 0.7rem;
            vertical-align: middle;
        }

        .navbar-center {
            text-align: center;
        }

        /*主体部分的样式*/
        .content {
            width: 100%;
        }

        /*搜索框样式*/
        .weui-grids:before, .weui-grids:after, .weui-grid:before {
            border: 0;
        }

        .weui-grid {
            padding: 0.5rem 0.4rem;
            background: #EFEFF4;
        }

        .weui-grid > input, .weui-grid > select {
            width: 100%;
            height: 1.5rem;
            color: #777;
            border: 1px #d9d9d9 solid;
            outline: none;
            border-radius: 0.3rem;
        }

        .weui-grid > input[type="text"] {
            padding-left: 0.2rem;
            height: 1.4rem;
        }

        .weui-grid > input[type="submit"] {
            font-size: 0.8rem;
            color: #F44444;
            line-height: 1.4rem;
            background: none;
            border: 0;
        }

        .weui-grid option {
            width: inherit;
            text-align: center;
        }

        .weui-grid {
            width: 80%;
        }

        .search {
            width: 20%;
        }

        /*列表处的样式*/
        .weui-cells {
            margin-top: 0.7rem;
            font-size: 0.7rem;
        }

        .weui-cell {
            padding: 0.4rem 0.5rem;
        }

        .weui-cell__hd {
            width: 6.0rem;
        }

        .status {
            margin-top: 0.2rem;
            font-size: 0.65rem;
        }

        .red {
            color: #F44444;
        }

        .blue {
            color: #468EE6;
        }

        .grey {
            color: #888;
        }

        .money {
            font-size: 0.65rem;
            color: #F44444;
        }

        .weui-cell__ft {
            padding-left: 0.2rem;
            font-size: 0.6rem;
        }

        .pagination > li {
            float: left;
            padding: 2px 6px;
            margin: 0 4px;
            list-style: none;
            color: #fff;
            background: #aaa;
            border-radius: 5px;
        }

        .pagination > li > a {
            color: #fff;
        }

        .pagination > li.active {
            background: #f44444;
        }
        .time {
            text-align: center;
        }
        .issue-dlog, .modify-dlog, .buy-dlog {
            position: fixed;
            top: 0px;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.4);
            z-index: 10000;
            display: block;
        }
        .issue-dlog1 {
            position: fixed;
            top: 0px;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.4);
            z-index: 10000;
            display: none;
        }

        .dlog {
            position: relative;
            top: 5rem;
            left: 0;
            margin: 0 auto;
            padding: 0.5rem;
            width: 14.5rem;
            height: auto;
            background: #fff;
            border-radius: 0.4rem;
            z-index: 100000;
        }
        .dlog1 {
            position: relative;
            top: 5rem;
            left: 0;
            margin: 0 auto;
            padding: 1rem;
            width: 14.5rem;
            height: auto;
            background: #fff;
            border-radius: 0.4rem;
            z-index: 100000;
        }
        .issue-close, .modify-close, .buy-close {
            position: absolute;
            top: 0rem;
            right: 0rem;
            width: 2rem;
            height: 1.4rem;
            text-align: center;
            line-height: 1.4rem;
            cursor: pointer;
        }

        .issueForm, .modifyForm, .buyForm {
            margin-top: 0.5rem;
            width: 100%;
            font-size: 0.65rem;
        }

        .issueForm > p, .modifyForm > p, .buyForm > p {
            display: block;
            width: 100%;
            height: 1.6rem;
            line-height: 1.6rem;
            margin-top: 0.4rem;
            margin-bottom: 0.3rem;
            text-align: center;
        }

        .issueForm > .visi, .modifyForm > .visi {
            margin-left: 0.25rem;
            text-align: left;
        }

        .issueForm input[type="text"],
        .modifyForm input[type="text"],
        .buyForm input[type="number"],
        .issueForm input[type="datetime"],
        .issueForm input[type="datetime-local"],
        .modifyForm input[type="datetime-local"] {
            padding-left: 0.3rem;
            width: 100%;
            height: 1.4rem;
            border: 0;
            border-bottom: 1px #F44444 solid;
            outline: 0;
        }

        .issuebtn,.issuebtn2, .modifybtn, .buybtn {
            width: 40%;
            height: 1.5rem;
            color: #FFFFFF;
            background: #F44444;
            border: 0;
            border-radius: 0.2rem;
            outline: 0;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .diya {
            margin-top: 5px;
            background-color: red;
        }
        .xianshi {
            display: flex;
            width: 100%;
            justify-content: space-between;
        }
        .check {
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 10px 0;
        }
        .xieyi {
            color: #999;
            font-size: 14px;
        }
    </style>
</head>
<body ontouchstart>
<header class="navbar">
    {if isset($user)}
    <a href="{:url('myteam/index')}" class="navbar-item">
        {else}
        <a href="{:url('index')}" class="navbar-item">
            {/if}
            <img src="__MODULE_LIBS__/img/back.png"/>&nbsp;{$is_language?'返回':'Return'}
        </a>
        <div class="navbar-center">{$is_language?'抵押':'mortgage'}</div>
        <div class="navbar-item1">
            <select name="" id="yy">
                <option value="1" {$is_language?'selected':''}>中文</option>
                <option value="0" {$is_language?'':'selected'}>English</option>
            </select>
        </div>
</header>
<div class="content">

</div>
<div class="issue-dlog">
    <div class="dlog">
        <form action="" method="post" class="issueForm">
                <!--<label>-->
                    <!--<span style="color: #F44444;">*</span>{$is_language?'抵押資產數量':'The number of mortgage assets'}：-->
                <!--</label><br>-->
                <!--<input type="text" name="sum" value=""/><br>-->


                <label>
                    <span style="color: #F44444;">*</span>{$is_language?'您需要貸款天數':'Mortgage days'}：
                </label><br>
                <div style="width: 100%;display: flex;align-items: center;justify-content: center;">
                <input style="width: 80%;height: 20px;border-radius: 5%;border: 1px solid #ddd;" type="number" name="day" value=""/>
                </div>

                <label>
                    <span style="color: #F44444;">*</span>{$is_language?'實際借款額度':'Borrowing amount'}：
                </label><br>
                <div style="width: 100%;display: flex;align-items: center;justify-content: center;">
                <input style="width: 80%;height: 20px;border-radius: 5%;border: 1px solid #ddd;" type="number" name="money" value=""/>
                </div>
                <div class="xianshi">
                    <span>{$is_language?'資產總價值':'The total value of assets'}:{$info['sum_money']}</span>
                    <span>{$is_language?'最高可抵押':'Maximum mortgage'}:${$info['mortgage_top_money']}</span>
                </div>
                <div style="width: 100%;text-align: center;margin-top: 5px;display: flex;justify-content: space-between;">
                    <a href="{:url('index')}" class="issuebtn2">{$is_language?'返回':'return'}</a>
                    <input type="button" class="issuebtn" value="{$is_language?'提交':'Issue assets?'}"/>
                    <input name="order_id" type="hidden" value="{$order_id}">
                </div>
        </form>
    </div>
</div>
<div class="issue-dlog1">
    <div class="dlog1">
        <span class="issue-close">X</span>
        <p>1、{$is_language?'按照約定用途使用出借，不得利用此款從事違法犯罪活動':'In accordance with the agreed use of loans, shall not use this money to engage in criminal activities'}</p>
        <p>2、{$is_language?'保證按本合同約定的時間、數額償還出借本息':'Guarantee according to the time and amount agreed in this contract, repay the loan principal and interest'}</p>
        <p>3、{$is_language?'當借款人出現危及償還出借安全的事件時，應最遲在事件發生後五日內書面告知出借人，並根據出借人的要求提前償還出借本息':'When the borrower endangers the event of repaying the loan safety, the lender should be informed in writing at least five days after the incident occurs and the loan principal should be repaid in advance according to the requirements of the lender'}</p>
        <p>4、{$is_language?'對已經獲知的出借人信息，資料予以保密':'Have been informed of the lender information, information to be kept confidential'}</p>
    </div>
</div>
<input type="hidden" name="yuyan" value="<?php echo @$is_language?>" id="yuyan">
<script src="https://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.min.js"></script>
<script src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/swiper.min.js"></script>
<script src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/city-picker.min.js"></script>
<script type="text/javascript">


        $('.issuebtn').click(function () {
            var order_id = $(this).next('input').val();
            var sum = $("input[name='sum']").val();
            var day = $("input[name='day']").val();
            var money = $("input[name='money']").val();
            var url = "{:url('order/lists')}";
            $(".issue-dlog").css('display', 'none');
            $('body').css({
                "overflow-x": "auto",
                "overflow-y": "auto"
            });
            $.post(url,{day:day,money:money,order_id:order_id},function (data) {
                console.log(data);
                if(data.code==0){
                    $.confirm({
                        title: '提示(confirm)',
                        text: data.msg,
                        onOK: function () {
                            window.history.back();
                        }
                    })
                }else{
                    var content = data.content;
                    var html = '';
                    var html1 = '<h style="padding: 0.4rem 0.5rem;font-weight: bold;">{$is_language?'請選擇借款人':'Please select a borrower'}</h>' ;
                    var html2 = '<div class="check"><input name="checkbox" type="checkbox" value="1"><a class="xieyi" href="javascript:void(0);">{$is_language?'抵押協議':'Mortgage agreement'}</a></div><div><a class="weui-btn weui-btn_primary diya" href="javascript:void(0);">{$is_language?'抵押':'Mortgage'}</a></div>'
                    for(var i=0; i<content.length; i++){
                        if(i==0){
                            html += '<div class="weui-cells weui-cells_radio"><label class="weui-cell weui-check__label" for="'+content[i].id+'"><div class="weui-cell__bd">'
                                +'<p>{$is_language?'出借人':'Mortgage'}：'+content[i].username+'</p><p>{$is_language?'日利率':'interest rate'}：'+content[i].mortgage*100+'%</p></div>'
                            +'<div class="weui-cell__ft"><input name="mortgage" type="hidden" value="'+content[i].mortgage+'"><input class="weui-check" checked name="radio1" id="'+content[i].id+'" value="'+content[i].id+'" type="radio">'
                            +'<span class="weui-icon-checked"></span></div></label></div>'
                        }else{
                            html += '<div class="weui-cells weui-cells_radio"><label class="weui-cell weui-check__label" for="'+content[i].id+'"><div class="weui-cell__bd">'
                                +'<p>{$is_language?'出借人':'Mortgage'}：'+content[i].username+'</p><p>{$is_language?'日利率':'interest rate'}：'+content[i].mortgage*100+'%</p></div>'
                            +'<div class="weui-cell__ft"><input name="mortgage" type="hidden" value="'+content[i].mortgage+'"><input class="weui-check" name="radio1" id="'+content[i].id+'" value="'+content[i].id+'" type="radio">'
                            +'<span class="weui-icon-checked"></span></div></label></div>'
                        }
                    }
                    $('.content').html(html1);
                    $('.content').append(html);
                    $('.content').append(html2);
                }
            })
        });

    $(document).on("click",'a.diya',function(){
        var id = $("input[name='radio1']:checked").val();
        var mortgage = $('input[name=radio1][checked]').prev('input').val();
        var url = "{:url('lists_ajax')}";
        var yuyan = $('#yuyan').val();
        if ($("input[name='checkbox']:checked").val()==1){
            $.confirm({
                title: '提示(confirm)',
                text: '確認抵押？（Confirm the mortgage?）',
                onOK: function () {
                    $.post(url,{mortgage_id:id,mortgage:mortgage},function (data) {
                        if(data.code==0){
                            $.alert({
                                title: '提示(confirm)',
                                text: data.msg,
                                onOK: function () {
                                    window.location.reload();
                                }
                            });
                        }else {
                            $.alert({
                                title: '提示(confirm)',
                                text: data.msg,
                                onOK: function () {
                                    location.href = "{:url('index/index')}";
                                }
                            });
                        }
                    })
                }
            });
        }else{
            $.alert({
                title: '提示(alert)',
                text: '請閱讀抵押協議並同意（Please read the mortgage agreement and agree）',
            })
        }
    });

    $(document).on("click",'a.xieyi',function(){
        $(".issue-dlog1").css('display', 'block');
        $('body').css({
            "overflow-x": "hidden",
            "overflow-y": "hidden"
        });
        //阻止默认
        $("body").on("touchmove", function (event) {
            event.preventDefault;
        }, false);
    });
$('.issue-close').click(function () {
    $(".issue-dlog1").css('display', 'none');
    $('body').css({
        "overflow-x": "auto",
        "overflow-y": "auto"
    });
    //然后点击取消或者确定时再取消body上的绑定
    $("body").off("touchmove");
});

    $(document).on("change",'select#yy',function(){
        var yy = $(this).val();
        console.log(yy)
        var url = "{:url('index/language')}";
        $.post(url,{language:yy},function (res) {
            window.location.reload();
        })
    });
    $(function () {
        FastClick.attach(document.body);
    })
</script>
</body>
</html>
